let t = require;
let e = module;
let o = e.exports;
o.default = e.exports;

('use strict');
console.log('start');
var _n33,
  i =
    (this && this.__extends) ||
    ((_n33 = function n(t, e) {
      return (_n33 =
        Object.setPrototypeOf ||
        ({
          __proto__: []
        } instanceof Array &&
          function (t, e) {
            t.__proto__ = e;
          }) ||
        function (t, e) {
          for (var o in e) {
            Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
          }
        })(t, e);
    }),
    function (t, e) {
      function o() {
        this.constructor = t;
      }
      _n33(t, e),
        (t.prototype =
          null === e
            ? Object.create(e)
            : ((o.prototype = e.prototype), new o()));
    });
Object.defineProperty(o, '__esModule', {
  value: !0
}),
  (o.BattleActor = void 0);
var r = t('AbsActor'),
  a = t('IdleAct'),
  s = t('AttackAct'),
  c = t('DieAct'),
  l = t('AbsInfo'),
  u = t('AppearAct'),
  h = t('AwaitAct'),
  p = t('ComUtils'),
  f = t('BattleUtils'),
  d = t('AwaitToAct'),
  g = t('MoveToAct'),
  _ = t('IdleToAct'),
  y = t('ResMrg'),
  C = t('BuffCtrl'),
  m = cc.Vec2,
  v = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.hang = e.entity),
        (e._buffCtrl = new C.BuffCtrl(e)),
        e._buffCtrl.on(r.ActorEvent.AddBuff, e.onAddBuff, e),
        e._buffCtrl.on(r.ActorEvent.RemoveBuff, e.onRemoveBuff, e),
        e
      );
    }
    return (
      i(e, t),
      (e.prototype.startAi = function () {
        this._aiCtrl && this._aiCtrl.start();
      }),
      (e.prototype.stopAi = function () {
        this._aiCtrl && this._aiCtrl.stop();
      }),
      Object.defineProperty(e.prototype, 'buffCtrl', {
        get: function get() {
          return this._buffCtrl;
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.addBuff = function (t) {
        this._buffCtrl && this.buffCtrl.addBuff(t);
      }),
      (e.prototype.onAddBuff = function () {
        this.isValid &&
          this.hp > 0 &&
          this.type == r.ActorType.Soldier &&
          this._info.build();
      }),
      (e.prototype.onRemoveBuff = function () {
        this.isValid &&
          this.hp > 0 &&
          this.type == r.ActorType.Soldier &&
          this._info.build();
      }),
      (e.prototype.removeBuff = function (t) {
        this.isValid && this._buffCtrl && this._buffCtrl.removeBuff(t);
      }),
      (e.prototype.getBuff = function (t) {
        if (this._buffCtrl) return this._buffCtrl.getBuff(t);
      }),
      (e.prototype.clearBuffs = function () {
        this._buffCtrl && this._buffCtrl.clearBuffs();
      }),
      Object.defineProperty(e.prototype, 'card', {
        get: function get() {
          return this._card;
        },
        set: function set(t) {
          (this._card = t),
            this.clearBuffs(),
            this._info.setBuff(this.buffCtrl);
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.loadModel = function (e) {
        (this.hit = this.entity), t.prototype.loadModel.call(this, e);
      }),
      (e.prototype.onInitModel = function (t) {
        var e = this.entity.scale;
        (this.weapon = p.default.findNode('ATTACHED_NODE:weapon', t)),
          (this.hit = p.default.findNode('ATTACHED_NODE:hit', t)),
          (this.hang = p.default.findNode('ATTACHED_NODE:hang', t)),
          (this.entity.scale = 0),
          this.toScale(e),
          (this._attackCD = 0);
      }),
      (e.prototype.setGridCard = function (t) {
        if (t)
          if (null == this._buffIcon) {
            var e = this;
            cc.resources.load(
              'Prefab/Effect/ActorBuffIcon',
              cc.Prefab,
              function (o, n) {
                o || ((e._buffIcon = cc.instantiate(n)), e.iniGridCard(t));
              }
            );
          } else this.iniGridCard(t);
      }),
      (e.prototype.iniGridCard = function (t) {
        if (this._buffIcon)
          if (t) {
            var e = p.default.getComponent(
              cc.Sprite,
              this._buffIcon,
              'imgBuffIcon'
            );
            (this._buffIcon.y = 204),
              t
                ? ((this._buffIcon.parent = this.entity),
                  y.ResMrg.loadSpriteByAtlas(e, 'Atlas/Battle', t.icon))
                : ((this._buffIcon.parent = null), (e.spriteFrame = null));
          } else this._buffIcon.parent = null;
      }),
      (e.prototype.getWeaponPoint = function () {
        var t = this.weapon.convertToWorldSpaceAR(m.ZERO);
        return this.entity.parent.convertToNodeSpaceAR(t);
      }),
      (e.prototype.getHitPoint = function () {
        var t = this.hit.convertToWorldSpaceAR(m.ZERO);
        return this.entity.parent.convertToNodeSpaceAR(t);
      }),
      (e.prototype.toScale = function (t) {
        this.type,
          r.ActorType.Soldier,
          cc
            .tween(this.entity)
            .to(
              0.2,
              {
                scale: t
              },
              {
                easing: 'elasticOut'
              }
            )
            .start();
      }),
      (e.prototype.aaa = function () {
        this.scene && this.scene.sortActor();
      }),
      Object.defineProperty(e.prototype, 'info', {
        get: function get() {
          return this._info;
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.revive = function () {
        var t = this.scale,
          e = this._info.hp;
        (this._info.hp = this._info.hpMax),
          (this.entity.active = !0),
          e <= 0 && ((this.entity.scale = 0), this.toScale(t)),
          this.clearState(),
          this.stopAction(),
          this.idleTo();
      }),
      (e.prototype.hurt = function (t, e) {
        this.state != r.ActorState.Die &&
          this._info &&
          ((this._info.hp -= t),
          this.emit(l.InfoEvent.HPChanged, this, t, e),
          this._info.hp <= 0 &&
            ((this._info.hp = 0), this.clearBuffs(), this.die()));
      }),
      Object.defineProperty(e.prototype, 'hp', {
        get: function get() {
          return this.state != r.ActorState.Die && this._info
            ? this._info.hp
            : 0;
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.idle = function () {
        this.act(a.IdleAct);
      }),
      (e.prototype.idleTo = function () {
        this.act(_.IdleToAct);
      }),
      (e.prototype.await = function () {
        this.stopAction(), this.act(h.AwaitAct);
      }),
      (e.prototype.awaitTo = function () {
        this.stopAction(), this.act(d.AwaitToAct);
      }),
      (e.prototype.attack = function (t) {
        this.stopAction(), this.act(s.AttackAct, t);
      }),
      (e.prototype.die = function () {
        this.stopAction(), this.act(c.DieAct);
      }),
      (e.prototype.appear = function () {
        this.stopAction(), this.act(u.AppearAct);
      }),
      (e.prototype.moveTo = function (t, e) {
        this.act(g.MoveToAct, t, e);
      }),
      (e.prototype.kill = function () {}),
      Object.defineProperty(e.prototype, 'attackCD', {
        get: function get() {
          return this._attackCD;
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.onUpdate = function (e) {
        if ((t.prototype.onUpdate.call(this, e), this.isPause))
          this.buffCtrl.update(e);
        else {
          var o = this.scene;
          o &&
            (this.state != r.ActorState.Appear &&
            this.state != r.ActorState.Await &&
            this.hp > 0
              ? ((this._attackCD -= e),
                this._attackCD <= 0 &&
                  ((null == this.target ||
                    (this.target && this.target.hp <= 0)) &&
                    (this.target = o.getTarget(this)),
                  this.target && this.attack(this.target),
                  (this._attackCD = f.default.AttackCD)))
              : (this._attackCD = 0)),
            this._aiCtrl && this._aiCtrl.update(e);
        }
      }),
      (e.prototype.onDestroy = function () {
        this._info && this._info.targetOff(this),
          t.prototype.onDestroy.call(this);
      }),
      e
    );
  })(r.AbsActor);
(o.BattleActor = v), console.log('end');
module.exports = e.exports;
